package com.decent.common.enums.sms;

/**
 * 短信相关错误编码枚举
 *
 * @author wangyx
 */
public enum SmsErrorCodeEnum {
    /**
     * 滑块验证码、短信相关错误集合
     * TODO-INIT 错误编码按项目需求进行修改
     */
    INVALID_SLIDE_VERIFY_CODE(201, "滑动验证码失效"),
    MEMBER_EXISTS(201, "用户已存在"),
    NO_MEMBER_EXISTS(201, "用户不存在"),
    VERIFY_CODE_FREQUENT(201, "短信发送频繁"),
    NO_VERIFY_CODE_SEND(201, "未发送短信验证码"),
    INVALID_VERIFY_CODE(201, "短信验证码有误"),
    SMS_SEND_FAIL(201, "短信发送失败");
    /**
     * 错误编码
     */
    private final Integer code;
    /**
     * 错误信息
     */
    private final String message;

    SmsErrorCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    @SuppressWarnings("unused")
    public static SmsErrorCodeEnum getEnumByCode(Integer code) {
        SmsErrorCodeEnum[] enums = SmsErrorCodeEnum.values();
        for (SmsErrorCodeEnum statusEnum : enums) {
            if (statusEnum.getCode().equals(code)) {
                return statusEnum;
            }
        }
        return null;
    }
}
